package com.surfilter.platform.data.dao;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Repository;

import com.ibatis.sqlmap.client.SqlMapClient;
import com.surfilter.platform.base.dao.DaoBase;
import com.surfilter.platform.data.model.ModuleModel;
import com.surfilter.platform.data.model.UserModel;

@Repository
public class InitDao extends DaoBase{

	@Resource(name = "platformSqlMapClient")
	private SqlMapClient sqlMapClient;

	public void initSqlMapClient() {
		this.setSqlMapClient(sqlMapClient);
	}

	public Map<String, String> getAllModulesForCache() {
		Map ret = (Map<String, String>) this.getMapByObject(
				"getAllModulesForCache", null, "moduleName", "serviceName");
		return ret;
	}
	
	public List<String> getUserPerModuleName(int userId) {
		Map<String, Object> param = new HashMap<String, Object>();
		param.put("userId", userId);
		List<String> modules = this.getListByObject("getUserPerModuleName",
				param);
		return modules;
	}
	
	public List<String> getUserPerModuleActionName(int userId) {
		Map<String, Object> param = new HashMap<String, Object>();
		param.put("userId", userId);
		List<String> actions = this.getListByObject("getUserPerModuleActionName",
				param);
		return actions;
	}
	
	public List<ModuleModel> getUserPerModules(int userId){
		Map<String, Object> param = new HashMap<String, Object>();
		param.put("id", userId);
		List<ModuleModel> modules = this.getListByObject("getUserPerModules",
				param);
		return modules;
	}
	
	public UserModel getUserByLogin(UserModel userModel) {
		UserModel retModel = (UserModel) this.getObjectByObject(
				"getUserByLogin", userModel);
		return retModel;
	}
}
